package com.dzq.controls{
/**
* @author Ethan.Du
 * @date 2008-05-28
 */	
import flash.display.Graphics;

import mx.controls.HSlider;
import mx.core.UIComponent;
import mx.core.mx_internal;
import mx.effects.SetStyleAction;
import mx.events.SliderEvent;

import com.dzq.controls.sliderClasses.BigThumbClass;

use namespace mx_internal;
	
public class RatingHSlider extends HSlider
{
	
	[Embed(source='../assets/RatingBar-0.gif')]
    private var bar0:Class;
    [Embed(source='../assets/RatingBar-1.gif')]
    private var bar1:Class;
    [Embed(source='../assets/RatingBar-2.gif')]
    private var bar2:Class;
    [Embed(source='../assets/RatingBar-3.gif')]
    private var bar3:Class;
    [Embed(source='../assets/RatingBar-4.gif')]
    private var bar4:Class;
    [Embed(source='../assets/RatingBar-5.gif')]
    private var bar5:Class;
    [Embed(source='../assets/RatingBar-X.gif')]
    private var barX:Class;
    
    [Embed(source='../assets/Slider-0.gif')]
    private var slider0:Class;
    [Embed(source='../assets/Slider-1.gif')]
    private var slider1:Class;
    [Embed(source='../assets/Slider-2.gif')]
    private var slider2:Class;
    [Embed(source='../assets/Slider-3.gif')]
    private var slider3:Class;
    [Embed(source='../assets/Slider-4.gif')]
    private var slider4:Class;
    [Embed(source='../assets/Slider-5.gif')]
    private var slider5:Class;
    [Embed(source='../assets/Slider-X.gif')]
    private var sliderX:Class;
    
    

            
	public function RatingHSlider()
	{
		super();
		
		//width = 205;	
		width = 215;				
		maximum = 5
		minimum = -1;
		snapInterval = 1;
		showDataTip = false;
		setStyle('trackSkin', barX);
  		setStyle('thumbSkin', sliderX);
  		setStyle('dataTipOffset', -5);
		setStyle('thumbOffset', -12);
  		sliderThumbClass = BigThumbClass;

  		addEventListener(SliderEvent.CHANGE, changeSkin);
	}
	
	/**
     *  @private
     */
    override protected function createChildren():void{	
    	super.createChildren();
    	var innerSlider:UIComponent = mx_internal::innerSlider
    	trace(innerSlider)
    	for(var i:int=0; i<innerSlider.numChildren; i++){
    		trace(innerSlider.getChildAt(i))
    	}
    	var u:UIComponent = innerSlider.getChildAt(1) as UIComponent;
    	var g:Graphics = u.graphics;
    	g.beginFill(0x3e3e3e);
    	g.drawRect(0,0,100,100);
    	
    }
    
    private function changeSkin(e:SliderEvent):void{
    	switch(value){	  					
  			case -1:
  				setStyle('trackSkin', barX);
  				setStyle('thumbSkin', sliderX);
  				break;
  			case 0:
  				setStyle('trackSkin', bar0);
  				setStyle('thumbSkin', slider0);
  				break;
  			case 1:
  				setStyle('trackSkin', bar1);
  				setStyle('thumbSkin', slider1);
  				break;
  			case 2:
  				setStyle('trackSkin', bar2);
  				setStyle('thumbSkin', slider2);
  				break;
  			case 3:
  				setStyle('trackSkin', bar3);
  				setStyle('thumbSkin', slider3);
  				break;
  			case 4:
  				setStyle('trackSkin', bar4);
  				setStyle('thumbSkin', slider4);
  				break;
  			case 5:
  				setStyle('trackSkin', bar5);
  				setStyle('thumbSkin', slider5);
  				break;
  		}
    }

}
}